package com.woniuxy.controller;

import com.woniuxy.entity.RbacMenu;
import com.woniuxy.entity.ResponseEntity;
import com.woniuxy.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class MenuCotroller {
    @Autowired(required = false)
    MenuService menuService;

    @GetMapping("/findMenu/{id}")
    public ResponseEntity findRbacManagerById(@PathVariable int id){
        RbacMenu rbacMenu = menuService.findMenuById(id);
        return new ResponseEntity(200,"查询成功",rbacMenu);
    }
    @PostMapping("/menuadd")
    public ResponseEntity add(@RequestBody RbacMenu rbacMenu){
        int i = menuService.add(rbacMenu);
        return new ResponseEntity(200,"添加成功",i);
    }
    @DeleteMapping("/menuDelete/{id}")
    public ResponseEntity menuDelete(@PathVariable int id){
        int i = menuService.menuDelete(id);
        return new ResponseEntity(200,"删除成功",i);
    }
    @PutMapping("updateMenu")
    public ResponseEntity updateMenu(@RequestBody RbacMenu rbacMenu){
        int i = menuService.updateMenu(rbacMenu);
        return new ResponseEntity(200,"修改成功",i);
    }
}
